﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Cms.Domain;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Cms.Tests.Unit.Domain
{

    [TestClass]
    public class LocaleTests
    {

        [TestMethod]
        public void GetTranslationByCultureCode()
        {
            Site site = new Site();
            Locale en = new Locale {ID = 1, Site = site, CultureCode = "en"};
            Locale sv = new Locale {ID = 2, Site = site, CultureCode = "sv"};
            site.Locales.Add(en);
            site.Locales.Add(sv);
            site.DefaultLocale = en;
            en.Translations.Add(1, new LocaleTranslation("Global", "Global", "English"));
            en.Translations.Add(2, new LocaleTranslation("Globalt", "Globalt", "Engelska"));
            sv.Translations.Add(2, new LocaleTranslation("Sverige", "Sverige", "Svenska"));
            sv.Translations.Add(1, new LocaleTranslation("Sweden", "Sweden", "Swedish"));
            Assert.AreEqual("Engelska", en.GetTranslation("sv").Language);
            Assert.AreSame(en.Translations[1], en.GetTranslation("xxx"));
        }

    }

}
